local gameRule = fk.CreateSkill {
    name = "ty_1v2_gamerule&",
}

local can_trigger = function(self, event, target, player, data)
    return (target == player) or (target == nil)
end

--城主起始手牌加成
gameRule:addEffect(fk.DrawInitialCards, {
    priority = 0.001,
    can_trigger = can_trigger,
    on_trigger = function(self, event, target, player, data)
        local room = player.room
        if player.role == "lord" then
          data.num = data.num + 1
        end
    end,
})

--兵尽（15轮后所有人崩坏）
gameRule:addEffect(fk.TurnEnd, {
    priority = 0.001,
    mute = true,
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        return target == player and player.room:getBanner("@[:]outofammunition") ~= nil
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:loseHp(player, 1, gameRule.name)
    end,
})

gameRule:addEffect(fk.RoundStart, {
    priority = 0.001,
    mute = true,
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        return (room:getBanner("RoundCount") > 2 and room:getBanner("@[:]growapart") == nil) or
        (room:getBanner("RoundCount") > 15 and room:getBanner("@[:]outofammunition") == nil)
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        if room:getBanner("@[:]growapart") == nil then
        room:setBanner("@[:]growapart", "GrowApart")
          for i = 1, 3, 1 do
          room:doBroadcastNotify("ShowToast",
            "联军出现嫌隙，从此轮开始，当有一位联军死亡城主即可获得胜利。")
          end
        elseif room:getBanner("RoundCount") > 15 and room:getBanner("@[:]outofammunition") == nil then
        room:setBanner("@[:]outofammunition", "OutOfAmmunition")
          for i = 1, 3, 1 do
          room:doBroadcastNotify("ShowToast",
            "兵尽粮绝，从本轮开始，所有角色须于其回合结束时失去1点体力。")
          end
        end
    end,
})

return gameRule
